package org.study.easyes.boot.service;

import org.dromara.easyes.core.conditions.select.LambdaEsQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.study.easyes.boot.entity.Product;
import org.study.easyes.boot.mapper.ProductMapper;

import java.util.List;

/**
 * 类的描述
 *
 * @author Administrator
 * @date 2022-10-25
 */
@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductMapper productMapper;

    @Override
    public int addProduct(Product product) {
        return productMapper.insert(product);
    }

    @Override
    public List<Product> searchByName(String title) {
        LambdaEsQueryWrapper<Product> queryWrapper = new LambdaEsQueryWrapper<>();
        queryWrapper.like(Product::getName, title);
        return productMapper.selectList(queryWrapper);
    }

    @Override
    public int deleteProduct(String id) {
        return productMapper.deleteById(id);
    }
}
